package com.rentdvd.client.servlet;

import java.io.IOException;
import java.rmi.RemoteException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.rentdvd.ws.RentDVDImplProxy;

@WebServlet(name="RegisterServlet", urlPatterns={"/register"})
public class RegisterServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public RegisterServlet() {
		super();
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String username = request.getParameter("username");
		String password = request.getParameter("password");
	
		RentDVDImplProxy service = new RentDVDImplProxy();
		try {
			//TODO : succcess or not
			service.register(username, password);
			
			request.getRequestDispatcher(("/login.jsp")).forward(request, response);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}
}